
package au.com.lastweekend.jim.actions;

import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;

import au.com.lastweekend.jim.controller.FullScreenController;
import au.com.lastweekend.jim.swing.SwingUtil;

/**
 * @author ggardner
 * 
 */
public class FullScreenNavigationAction extends AbstractAction {

    private static final long serialVersionUID = 1L;

    public enum NavigationType {
        PREVIOUS("Previous", "resultset_previous.png", "Show previous image"), NEXT("Next", "resultset_next.png",
                "Show next image"), CLOSE("Close", "photos.png", "Close full screen");

        private String typeName;
        private String description;
        private String iconPath;

        NavigationType(String name, String iconPath, String description) {

            this.typeName = name;
            this.description = description;
            this.iconPath = iconPath;
        }
    }

    private final FullScreenController controller;

    public FullScreenNavigationAction(FullScreenController controller, NavigationType type) {

        super(type.typeName);
        this.controller = controller;
        putValue(SwingUtil.TOOLBAR, Boolean.TRUE);
        putValue(ACTION_COMMAND_KEY, type.name());
        SwingUtil.setActionParameters(this, type.iconPath, type.description, type.description);

    }

    public void actionPerformed(ActionEvent e) {

        String name = e.getActionCommand();

        if (NavigationType.CLOSE.name().equals(name)) {
            this.controller.closeFullScreen();
        } else if (NavigationType.NEXT.name().equals(name)) {
            this.controller.showNext();
        } else if (NavigationType.PREVIOUS.name().equals(name)) {
            this.controller.showPrevious();
        }

    }
}